#ifndef Scenic_Renderer_common_h
#define Scenic_Renderer_common_h

#include <stdio.h>
#include <math.h>
#include <string.h>

#ifdef DIRECTX
#include <windows.h>
#include <d3dx9.h>
#endif
#ifdef OPT_OPENGL
#include <GL/gl.h>
#ifdef OPT_X11
#include <X11/X.h>
#include <GL/glx.h>
#endif
#include "GLExtensions.h"
#endif

#ifndef M_PI
	#define M_PI 3.1415926535
#endif

#ifdef OPT_X11
	#define __stdcall
#endif

#ifdef DIRECTX
#define strdup _strdup
#endif

#ifndef max
	#define max(a, b) ((a) > (b) ? (a) : (b))
	#define min(a, b) ((a) < (b) ? (a) : (b))
#endif


namespace Scenic
{
namespace Renderer
{

enum Format
{
	FMT_A8R8G8B8 = 0,
	FMT_R8G8B8 = 1,
	FMT_L8 = 2,
	FMT_A8 = 3,
	FMT_AL8 = 4,
	FMT_A16B16G16R16F = 5,
	FMT_COUNT
};

enum Usage
{
	USAGE_RENDER_TARGET = 1
};

enum CapStyle
{
	BUTT_CAP = 0,
	ROUND_CAP = 1,
	SQUARE_CAP = 2
};

enum JoinStyle
{
	MITER_JOIN = 0,
	ROUND_JOIN = 1,
	BEVEL_JOIN = 2
};

enum GradientType
{
	LINEAR = 0,
	RADIAL = 1,
	SQUARE = 2,
	CONICAL = 3
};

enum SurfaceType
{
	SURFACE_TYPE_COLOR = 0,
	SURFACE_TYPE_ALPHA = 1,
	SURFACE_TYPE_ALPHA2X = 2,
	SURFACE_TYPE_ALPHA4X = 3
};

enum AttributeType
{
	ATTRIBUTE_TYPE_CHAR = 0,
	ATTRIBUTE_TYPE_SHORT = 1,
	ATTRIBUTE_TYPE_INT = 2,
	ATTRIBUTE_TYPE_FLOAT = 3
};

enum Attribute
{
	POSITION_ATTRIBUTE = 0,
	COLOR_ATTRIBUTE = 1,
	TEX_COORD1_ATTRIBUTE = 2,
	ATTRIBUTE_SIZE
};

enum FragmentParameter
{	
	COLOR_FP = 0,
	FP_SIZE = 1
};

#define PRIMITIVE_MAX_TEXTURES 1

// #include "PolygonRenderer.h"

char *getErrorName(int code);

}
}

#include "Util.h"
#include "Resource.h"
#include "Graphics.h"

#include "VertexStore.h"
#include "Image.h"
#include "Context.h"
#include "LineRenderer.h"

namespace Scenic
{
namespace Renderer
{
extern CriticalSection renderingLock;
}
}

#endif
